<?php

session_start();

$id = $_POST[id];
$_SESSION['id'] = $id;
// echo $id;
// var_dump($_SESSION['id']);

// var_dump($_POST);
$h      = date('Y-m-d H-i-s');
$liuyan = strip_tags($_POST['liuyan']);
// var_dump($liuyan);

//第一步连接数据库服务器；
@mysql_connect('localhost', 'root', 'root');
//第二步判断是否正确连接；
if (mysql_errno()) {
    die(mysql_error());

}
//第三步选择数据库
mysql_select_db('blog');
//第四步设置字符集
mysql_set_charset('utf8');
//第五步写入SQL语句
$sql = "insert into `pinglun` (`pid`,`uid`,`ctime`,`content`)values('{$_POST['id']}','{$_POST['user']}','{$h}','{$liuyan}')";
$res = mysql_query($sql);
if ($res) {
	
    echo "<script>
     alert('评论成功');window.location.href='./text1.php?id=$id'</script>";
} else {
    echo "<script>
     alert('评论失败');window.location.href='./text1.php'</script>";
}

?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
<form action="">

  <input  type="hidden" value="<?php echo $id; ?>" name="id">
</form>

</body>
</html>